﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;

namespace Nirvana
{
    /// <summary>
    /// 检测哪些材质球使用了内置Standerd Shader
    /// </summary>
    [Serializable]
    public sealed class CheckStanderdMaterial
    {
        private enum StanderdMode
        {
            [EnumLabel("Not Check")]
            NotCheck,
            [EnumLabel("Check")]
            Check
        }

        [SerializeField]
        [EnumLabel]
        [Tooltip("The Standerd Shader Material check mode.")]
        private StanderdMode standerdMaterialMode;

        [SerializeField]
        [EnumLabel]
        [Tooltip("The Particle Standard Surface Material check mode.")]
        private StanderdMode particleStandardSurfaceMaterialMode;

        public void CheckMaterials(AssetCheckReport report, Material mat)
        {
            if (this.standerdMaterialMode == StanderdMode.Check && mat.shader.name == "Standard")
            {
                string assetPath = AssetDatabase.GetAssetPath(mat.shader.GetInstanceID());
                if (!assetPath.StartsWith("Assets/Resources/Shader"))  // 所有内置shader文件都放到shader目录
                {
                    report.ShowWarnInfo("The material <b><color=orange>{0}</color></b> Use of <b><color=orange>Standerd</color></b> Shader!!", mat.name);
                }
            }

            if (this.particleStandardSurfaceMaterialMode == StanderdMode.Check && mat.shader.name == "Particles/Standard Surface")
            {
                string assetPath = AssetDatabase.GetAssetPath(mat.shader.GetInstanceID());
                if (!assetPath.StartsWith("Assets/Resources/Shader"))  // 所有内置shader文件都放到shader目录
                {
                    report.ShowWarnInfo("The material <b><color=orange>{0}</color></b> Use of <b><color=orange>Particles/Standard Surface</color></b> Shader!!", mat.name);
                }

            }
        }


    }
}

